/*
 * <p>Copyright® 2009-2022 东软 IT 实训中心版权所有。</p>
 */

package com.max.back.doctor.api;

import com.max.back.common.http.ResponseResult;
import com.max.back.doctor.form.PatientHistoryForm;
import com.max.back.doctor.form.groups.CreateAndGetPrescriptionId;
import com.max.back.doctor.service.PrescriptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author 辛凤文 forward.seen@foxmail.com
 * @version 1.0
 * @description <p>
 * <code>PrescriptionApi</code>
 *
 * </p>
 * @time 2022/7/27 21:25
 * @see
 */
@RestController
@RequestMapping("/prescription")
@CrossOrigin
public class PrescriptionApi {

    @Autowired
    private PrescriptionService prescriptionService;

    @PostMapping("/createAndReturnPrescription")
    public ResponseResult<String> createAndReturnPrescription(
            @RequestBody @Validated
                    (CreateAndGetPrescriptionId.class) PatientHistoryForm phi) {
        String prescriptionId =
                prescriptionService.createAndGetPrescription(phi.getPatientHistoryId());
        return ResponseResult.getSuccessResult(prescriptionId);
    }
}